package com.pearl.jacksoncore.demo.databind.ser;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.util.VersionUtil;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ext.SqlBlobSerializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.module.SimpleSerializers;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
import com.fasterxml.jackson.databind.ser.SerializerFactory;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author TD
 * @version 1.0
 * @date 2024/4/8
 */
public class Test {

    public static void main(String[] args) throws JsonProcessingException {
        // 创建 ObjectMapper
        ObjectMapper objectMapper = new ObjectMapper();
        // 获取原有的 SerializerFactory
        SerializerFactory serializerFactory = objectMapper.getSerializerFactory();
        // 创建额外序列化器
        SimpleSerializers simpleSerializers = new SimpleSerializers();
        simpleSerializers.addSerializer(new SqlBlobSerializer());
        // SerializerFactory 添加自定义的序列化器
        SerializerFactory newSerializerFactory = serializerFactory.withAdditionalSerializers(simpleSerializers);
        // 重新设置给 ObjectMapper（因为SerializerFactory 是不可变对象， with 方法返回新的实例）
        objectMapper.setSerializerFactory(newSerializerFactory);

        SerializerProvider serializerProvider = objectMapper.getSerializerProvider();
        JsonSerializer<Object> defaultNullValueSerializer = serializerProvider.getDefaultNullValueSerializer(); // 获取默认的null 值序列化器
        DeserializationContext deserializationContext = objectMapper.getDeserializationContext();
        DefaultSerializerProvider.Impl defaultSerializerProvider = new DefaultSerializerProvider.Impl();

        objectMapper.configure(SerializationFeature.EAGER_SERIALIZER_FETCH, true);

        System.out.println(SerializationFeature.WRAP_ROOT_VALUE.getMask());
        System.out.println(SerializationFeature.INDENT_OUTPUT.getMask());
        System.out.println(SerializationFeature.FAIL_ON_EMPTY_BEANS.getMask());
        System.out.println(SerializationFeature.FAIL_ON_SELF_REFERENCES.getMask());
        System.out.println(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID.getMask());

        System.out.println(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS.getMask());


        System.out.println(GenderEnum.MAN);



    }
}
